<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 时间复杂度 O(n) 空间复杂度O(1) -->
</head>
<body>
    <script>
        var reverseList = function(head) {
            p1 = head;
            p2 = null;
            while (p1) {
                let tmp = p1.next;
                p1.next = p2;  // 反转
                p2 = p1; // 前移
                p1 = tmp; // 前移
            }
            return p2;
        };
    </script>
</body>
</html>